﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Sobiens.Connectors.Entities
{
    [DataContract(Namespace = "")]
    public class CamlFilter
    {
        public string FieldName { get; set; }
        public CamlFilterTypes FilterType  { get; set; }
        public string FilterValue { get; set; }
        public FieldTypes FieldType { get; set; }
        public CamlFilter(Search.SearchFilter searchFilter)
        {
            this.FieldName = searchFilter.FieldName;
            this.FieldType = searchFilter.FieldType;
            this.FilterType = searchFilter.FilterType;
            this.FilterValue = searchFilter.FilterValue;
        }

        public CamlFilter(string fieldName, FieldTypes fieldType, CamlFilterTypes filterType, string filterValue)
        {
            FieldName = fieldName;
            FieldType = fieldType;
            FilterType = filterType;
            FilterValue = filterValue;
        }
        public string GetCamlString()
        {
            /*
            string caml = String.Empty;
            string fieldTypeString = SPCamlManager.GetCamlFieldTypeString(this.FieldType);
            string filterTypeString = SPCamlManager.GetCamlFilterTypeString(this.FilterType);
            caml = "<" + filterTypeString + "><Value Type=\"" + fieldTypeString + "\"><![CDATA[" + this.FilterValue + "]]></Value><FieldRef Name=\"" + this.FieldName + "\"/></" + filterTypeString + ">";
            return caml;
             */
            return string.Empty;
        }
    }
}
